<script setup>
  import { onMounted, ref } from 'vue';
  import MyForm from './components/MyForm.vue';
  const formRef = ref(null)

  onMounted(() => {
    // 必须在挂载后才能访问到 不然就是 null
    console.log(formRef.value.formCheck())
  })

  const login = () => {
    console.log(`${formRef.value.formCheck() ? '登入成功' : '登入失败'}`);
  }
</script>

<template>
  <div>
    <MyForm ref="formRef" />
    <button @click="login">登 入</button>
  </div>
</template>

<style scoped></style>